﻿using Microsoft.AspNetCore.Mvc;
using WCS_Entity.Dto;
using WCS_Entity.Dto.UserDto;
using WCS_Service.Interface;

namespace WCS.Controllers
{
    /// <summary>
    /// 权限菜单接口
    /// </summary>
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class MenuController : ControllerBase
    {
        private readonly IMenuService _menuService;
        public MenuController(IMenuService menuService) 
        {
            _menuService = menuService;
        }
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="menuId"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<WebApiCallBack> QueryMenuAsync(int menuId)
        {
            var result = new WebApiCallBack();
            var menuInfo = await _menuService.QueryMenuAsync(menuId);
            if (menuInfo is null)
            {
                result.status = false;
                result.msg = "权限菜单获取失败";
                return result;
            }
            result.data = menuInfo;
            return result;
        }
        /// <summary>
        /// 查询所有权限菜单信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<WebApiCallBack> QueryAllMenuAsync()
        {
            var result = new WebApiCallBack();
            var menuInfos = await _menuService.QueryAllMenuAsync();
            if (menuInfos is null)
            {
                result.status = false;
                result.msg = "所有权限菜单获取失败";
                return result;
            }
            result.data = menuInfos;
            return result;
        }
    }
}
